<template>
  <div class="energy-use-view">
    <div class="energy-use-view-header">
      <div class="energy-use-view-header-left">
        <div>
          <span>用电类别</span>
          <span>大工业</span>
          <span>公线专变客户</span>
          <span>110KV</span>
          <span>高供高计</span>
        </div>
        <div>用电周期：{{ store.state.totalCount.startDate }}-{{ store.state.totalCount.endDate }}　　　　抄表日：每月{{ store.state.totalCount.estimateDate }}号</div>
      </div>
      <div class="energy-use-view-header-right">
        <div>
          <el-date-picker
            size="large"
            value-format="YYYY-MM"
            v-model="store.state.totalCount.month"
            default-value="new Date()"
            type="month"
            placeholder="请选择时间"
            @change="store.dispatch('initEnergyuse',{page:'energyuse'})"
          />
        </div>
        <div>
          <el-select
            v-model="province"
            @change="customer = companyList[0]?.id"
            class="m-2"
            placeholder="选择城市"
            size="large"
          >
            <el-option
              v-for="item in $store.state.areaList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </div>
        <div>
          <el-select v-model="customer"  class="m-2" placeholder="选择公司" size="large">
            <el-option
              v-for="item in companyList"
              :key="item.title"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </div>
      </div>
      <div style="clear: both"></div>
    </div>
    <div>
      <div class="item">
        <frame-block title="本月用电">
          <div class="byyd">
            <div>
              <img src="@/assets/images/EnergyUseView/dl.png" alt="" />
              <div>
                <p>
                  <span>电量</span
                  ><span class="color3dfefc"
                    ><span class="size28"><round :value="store.state.totalCount.monthQuantities" /></span
                    ><span class="size16">kwh</span></span
                  >
                </p>
                <p>
                  <span>
                    <span>同比</span>
                    <span  v-if="store.state.totalCount.monthQuantitiesSRatio != '--'" class="color3dfefc size16"> <round :value="store.state.totalCount.monthQuantitiesSRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthQuantitiesSRatio === '--'" class="color3dfefc size16"> {{ store.state.totalCount.monthQuantitiesSRatio }}</span>
                    <img v-if="store.state.totalCount.monthQuantitiesSRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthQuantitiesSRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                  <span>
                    <span>环比</span>
                    <span  v-if="store.state.totalCount.monthQuantitiesCRatio != '--'" class="color3dfefc size16"> <round :value="store.state.totalCount.monthQuantitiesCRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthQuantitiesCRatio === '--'" class="color3dfefc size16"> {{ store.state.totalCount.monthQuantitiesCRatio }}</span>
                    <img v-if="store.state.totalCount.monthQuantitiesCRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthQuantitiesCRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                </p>
              </div>
            </div>
            <div>
              <img src="@/assets/images/EnergyUseView/df.png" alt="" />
              <div>
                <p>
                  <span>电费</span>
                  <span class="colorFFD800"><span class="size28"><round :value="store.state.totalCount.monthQuantitiesCost"/>
                  </span><span class="size16">元</span></span>
                </p>
                <p>
                  <span>
                    <span>同比</span>
                    <span  v-if="store.state.totalCount.monthQuantitiesCostSRatio != '--'" class="colorFFD800 size16"> <round :value="store.state.totalCount.monthQuantitiesCostSRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthQuantitiesCostSRatio === '--'" class="colorFFD800 size16"> {{ store.state.totalCount.monthQuantitiesCostSRatio }}</span>
                    <img v-if="store.state.totalCount.monthQuantitiesCostSRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthQuantitiesCostSRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                  <span>
                    <span>环比</span>
                    <span  v-if="store.state.totalCount.monthQuantitiesCostCRatio != '--'" class="colorFFD800 size16"> <round :value="store.state.totalCount.monthQuantitiesCostCRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthQuantitiesCostCRatio === '--'" class="colorFFD800 size16"> {{ store.state.totalCount.monthQuantitiesCostCRatio }}</span>
                    <img v-if="store.state.totalCount.monthQuantitiesCostCRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthQuantitiesCostCRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>

                </p>
              </div>
            </div>
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="本月实际功率因数">
          <div class="byyd sjgl">
            <div>
              <img src="@/assets/images/EnergyUseView/gl.png" alt="" />
              <div>
                <p>功率因数</p>
                <p class="sjgl_c color1DF9BA">
                  <span class="size28"><round :value="store.state.totalCount.pfc" /></span><span>考核{{ store.state.totalCount.evaluation }}</span>
                </p>
                <p>
                  <span>
                    <span>同比</span>
                    <span  v-if="store.state.totalCount.pfcSRatio != '--'" class="size16 color3dfefc"> <round :value="store.state.totalCount.pfcSRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.pfcSRatio === '--'" class="size16 color3dfefc"> {{ store.state.totalCount.pfcSRatio }}</span>
                    <img v-if="store.state.totalCount.pfcSRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.pfcSRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                  <span>
                    <span>环比</span>
                    <span  v-if="store.state.totalCount.pfcCRatio != '--'" class="size16 color3dfefc"> <round :value="store.state.totalCount.pfcCRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.pfcCRatio === '--'" class="size16 color3dfefc"> {{ store.state.totalCount.pfcCRatio }}</span>
                    <img v-if="store.state.totalCount.pfcCRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.pfcCRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                </p>
                <p></p>
              </div>
            </div>
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="碳排放">
          <div class="byyd sjgl">
            <div>
              <img src="@/assets/images/EnergyUseView/tpf.png" alt="" />
              <div>
                <p>碳排放量</p>
                <p class="sjgl_c color3dfefc">
                  <span class="size28">
                    <span class=""><round :value="store.state.totalCount.monthCarbonEmission" />
                    </span><span class="size16">kg</span>
                  </span>
                </p>
                <p>
                  <span>
                    <span>同比</span>
                    <span  v-if="store.state.totalCount.monthCarbonEmissionSRatio != '--'" class="size16 color3dfefc"> <round :value="store.state.totalCount.monthCarbonEmissionSRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthCarbonEmissionSRatio === '--'" class="size16 color3dfefc"> {{ store.state.totalCount.monthCarbonEmissionSRatio }}</span>
                    <img v-if="store.state.totalCount.monthCarbonEmissionSRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthCarbonEmissionSRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                  <span>
                    <span>环比</span>
                    <span  v-if="store.state.totalCount.monthCarbonEmissionCRatio != '--'" class="size16 color3dfefc"> <round :value="store.state.totalCount.monthCarbonEmissionCRatio" />%</span>
                    <span  v-else-if="store.state.totalCount.monthCarbonEmissionCRatio === '--'" class="size16 color3dfefc"> {{ store.state.totalCount.monthCarbonEmissionCRatio }}</span>
                    <img v-if="store.state.totalCount.monthCarbonEmissionCRatioArrow < 0" src="@/assets/images/components/xj.png" alt=""/>
                    <img v-if="store.state.totalCount.monthCarbonEmissionCRatioArrow > 0" src="@/assets/images/components/ss.png" alt=""/>
                  </span>
                </p>
                <p></p>
              </div>
            </div>
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="电量结构">
          <div class="dljg">
            <doughnut-chart />
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="电费结构">
          <div class="dfjg">
            <GanttChartofAirportFlights />
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="每日电量">
          <div class="mrdl">
            <lineAndbarEcharts title="mrdl" id="mrdl" valueType="mrdl" />
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="每日电费">
          <div class="mrdl">
            <lineAndbarEcharts title="mrdf" id="mrdf" valueType="mrdf" />
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="用电成本K指数">
          <div class="mrdl">
            <lineAndbarEcharts id="ydcbkzs" type="line" valueType="ydcbkzs" />
          </div>
        </frame-block>
      </div>
      <div class="item">
        <frame-block title="变压器负载率">
          <div class="mrdl">
            <lineAndbarEcharts id="byqfzl" type="line" valueType="byqfzl" />
          </div>
        </frame-block>
      </div>
    </div>
    <br />
  </div>
</template>

<script setup>
import { ref, onMounted, watch, reactive, computed } from 'vue'
import { useStore } from 'vuex'
const store = useStore()
store.state.pageName = "energyuse"

import { useRouter, useRoute } from 'vue-router'
const route = useRoute()

const customer = ref(store.state.customer)
const province = ref(store.state.province)
let customerObj = store.state.companyList.filter((e) => e.id == store.state.customer)[0]
if (customerObj) {
  if (customerObj.provinceId) {
    province.value = customerObj.provinceId
  }
}


const companyList = computed(function () {
  if (province.value == 0) {
    return store.state.companyList
  } else if (province.value) {
    return store.state.companyList.filter((e) => {
      return e.provinceId == province.value
    })
  } else {
    return store.state.companyList
  }
})

watch([customer] ,
    () => {
      store.state.customer = customer.value
      store.dispatch('setCustomer',customer.value);
    },
    { immediate: true }
)

watch( [province],
  () => {
    store.state.province = province.value
  },
  { immediate: true }
)

onMounted(() => {
  
})
</script>

<style lang="scss" scoped>
.mrdl {
  width: 1540px;
  height: 360px;
}
.dfjg {
  width: 1020px;
  height: 360px;
}
.dljg {
  width: 500px;
  height: 360px;
}
.byyd {
  width: 500px;
  padding: 40px 40px 0 35px;
  & > div {
    margin-bottom: 40px;
    display: flex;
    align-items: center;
    div:nth-child(2) {
      flex-grow: 1;
      height: 90px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      & > p {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      img {
        width: 16px;
      }
    }
    & > img {
      width: 106px;
      margin-right: 10px;
      height: 98px;
    }
  }

  .size28 {
    font-weight: 900;
    font-size: 28px;
  }
  .size16 {
    font-weight: 900;
    font-size: 16px;
  }

  .colorFFD800 {
    color: #ffd800;
  }
  .color3dfefc {
    color: #3dfefc;
  }

  .color1DF9BA {
    color: #1df9ba;
  }
}

.sjgl {
  padding: 40px 40px 10px 15px;
  & > div {
    div:nth-child(2) {
      flex-grow: 1;
      height: 227px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .sjgl_c {
        padding-bottom: 50px;
      }
      img {
        width: 16px;
      }
    }
    & > img {
      width: 198px;
      height: 227px;
    }
  }
}

.energy-use-view {
  padding-top: 25px;
  font-size: 18px;
  color: #fcf8f8;
  width: 100%;
  .item {
    display: inline-block;
  }
}
.energy-use-view-header-left {
  float: left;
  font-size: 14px;
  & > div:nth-child(1) span {
    color: #3cfdfb;
    padding: 5px 16px;
    background-image: url('@/assets/images/EnergyUseView/headBr.png');
    background-size: 100% 100%;
  }
  & > div:nth-child(2) {
    padding: 15px 17px;
  }
}
.energy-use-view-header-right {
  float: right;
  & > div {
    display: inline-block;
    margin-right: 20px;
  }
}

:deep(.el-input__wrapper) {
  background-color: #fff0;
}
</style>